<include file="Public:header" />
<form class="form-inline definewidth m20" action="{:U('Home/FaultRecords/index')}" method="get">    
    记录编号：
    <input type="text" name="records_no" id="records_no"class="abc input-default" placeholder="" value="{$records_no}"> 
    <button type="submit" class="btn btn-primary" name="search">查询</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <select name="type" id="sta-type">
        <option value="1">分设备查询</option>
        <option value="2" selected >总体查询</option>
    </select>
    <button type="submit" class="btn" name="statistics">故障统计</button>
    <button type="button" class="btn btn-success" id="addnew">新增记录</button>
</form>
<table class="table table-bordered table-hover definewidth m10">
    <thead>
    <tr>
        <th></th>
        <th>记录编号</th>
        <th>设备编号</th>
        <th>故障时间</th>
        <th>操作</th>
    </tr>
    </thead>
	     <foreach name="list" item="l_val" key="lk">
        <tr>
            <td>{$lk+1}</td>
            <td>{$l_val.records_no}</td>
            <td>{$l_val.equipment_number}({$l_val.equname})</td>
            <td>{$l_val.fault_time|date='Y-m-d',###}</td>
            <td>
                <a href="{:U('Home/FaultRecords/view',array('recid'=>$l_val['fault_records_id']))}" title="查看" ><icon class="icon-eye-open" ></icon></a>
                <a href="{:U('Home/FaultRecords/edit',array('recid'=>$l_val['fault_records_id']))}" title="编辑" ><icon class="icon-edit" ></icon></a>
                <a href="javascript:delete_user({$l_val['fault_records_id']})" title="删除"><icon class="icon-trash" ></icon></a>
            </td>
        </tr>
    </foreach>
</table>
<script>
    $(function () {

        $('#addnew').click(function(){

            window.location.href="{:U('Home/FaultRecords/add')}";
        });
    });

    function delete_user(id)
    {
        if(confirm("确定要删除吗？"))
        {
            $.get("{:U('Home/FaultRecords/delete',array('recid'=>$l_val['fault_records_id']))}",function (xhr) {
                if(200 == xhr.status){
                    alert(xhr.msg);
                    window.location.href="{:U('Home/FaultRecords/Index')}";
                }else{
                    alert(xhr.msg);
                }
            });
        }
    }
    // function statistics(){
    //     type = $("sta-type").selected.value;
        
    //     $.get("{:U('Home/FaultRecords/statistics',array('type'=>"+type+"))}",function (xhr) {
    //             if(200 == xhr.status){
    //                 window.location.href="{:U('Home/FaultRecords/Index')}";
    //             }else{
    //                 alert(xhr.msg);
    //             }
    //         });
    // }
</script>

<include file="Public:footer" />

